/*
 * 作者: @一只小初尘
 * 制作时间: 2023年2月15日
 * 作者致辞: 已经路过的风景不要再打听，失而复得的东西回不到最初的样子。
 */

//引用jQuery,如果没有引用则引用需要把jQuery外链放到该文件上面,否则会重复引用jQuery
try {
    $
} catch {
    //判断当前网络状态
    if (navigator.onLine) {
        document.write("<script src='https://code.jquery.com/jquery-3.7.0.min.js'></script>");
    } else {
        //无网络状态
    }
}

var 时间;

function time() {
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var dayinmonth = date.getDate();
    var hour = date.getHours();
    var minutes = date.getMinutes();
    var seconds = date.getSeconds();
    var milli = date.getMilliseconds();
    if (month < 10) {
        month = "0" + month;
    }
    if (dayinmonth < 10) {
        dayinmonth = "0" + dayinmonth;
    }
    if (hour < 10) {
        hour = "0" + hour;
    }
    if (minutes < 10) {
        minutes = "0" + minutes;
    }
    if (seconds < 10) {
        seconds = "0" + seconds;
    }
    if (milli < 10) {
        milli = "0" + milli
    }
    时间 = year + "-" + month + "-" + dayinmonth + " " + hour + ":" + minutes + ":" + seconds + "   ";
    setTimeout('time()', 100);
}
window.onload = time();
//提示框控制
var $lcn = {
    name: 'message-item', //为防止class有重复值可以在这里设置
    left: 350, //左边缘
    width: '800',
    num: 10, //消息数量
    lcn: 6, //距离顶部的高度
    sum: 35, //每个消息高低间隔 间隔算法
    timer: 3, //消失的时间
    bgcolor: "#2db2ff", //背景颜色
    opacity: '0.6', //透明度
    shadow: "0 0 1px #2db2ff, 0 0 3px #2db2ff, 0 0 6px #2db2ff,0 0 12px #2db2ff", //消息阴影
};
// 渐变色控制
var ramp = {
    name: 'Shadow', //样式名称,可以自定义防止与其他名冲突
    deg: '-45deg', //渐变角度
    bgcolor: 'red,orange,green,cyan,blue,violet', //背景颜色
    position: 240, //宽度
    speed: 2, //渐变的速度,值为0时为静态
}
window.onload = function () {
    var style = document.createElement('style');
    document.head.appendChild(style);
    sheet = style.sheet;
    sheet.addRule("body", "-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;-khtml-user-select: none;user-select: none;");
    sheet.addRule(".none", "display: none !important;");
    sheet.addRule("." + $lcn.name, "position: fixed;text-decoration: none;height: 40px;pointer-events: none;display: none;color: #fff;left: " + $lcn.left + "px;width: " + $lcn.width + "px;padding: 0px 20px 0px 20px;background-color: " + $lcn.bgcolor + ";text-align: center;line-height: 40px;border-radius: 10px 10px 10px 10px;z-index: 9999;opacity: " + $lcn.opacity + ";box-shadow: " + $lcn.shadow + ";");
    sheet.addRule("." + $lcn.name + " a", "text-decoration: none;color: #1eff45;display: inline-block;line-height: 40px;");
    sheet.addRule("@keyframes remove", "0% {opacity: 0;}10% {opacity: .8;}100% {opacity: .2;}");
    sheet.addRule(".Btn", "outline: none;clip-path: inset(0 round 5px);border: 2px solid;background-image: -webkit-linear-gradient(top, rgb(111, 255, 0), rgba(220, 20, 60, 0.392));-webkit-background-clip: text;-webkit-text-fill-color: transparent;border-image-source: linear-gradient(90deg, rgb(111, 255, 0), rgba(220, 20, 60, 0.392));border-image-slice: 1;animation: huerotate 5s infinite linear;display: inline-block;cursor: pointer;");
    sheet.addRule("@keyframes huerotate", "0% {filter: hue-rotate(0deg);}100% {filter: hue-rotate(360deg);}");
    sheet.addRule("." + ramp.name + "", "background-image: -webkit-linear-gradient(" + ramp.deg + ", " + ramp.bgcolor + ");background-size: " + ramp.position + "px;-webkit-background-clip: text;-webkit-text-fill-color: transparent;display: inline-block;cursor: pointer;animation: " + ramp.name + " " + ramp.speed + "s infinite linear;");
    sheet.addRule("@keyframes " + ramp.name + "", "0%{background-position: 0%;}100%{background-position: " + ramp.position + "px;}");

    for (let i = 1; i <= $lcn.num; i++) {
        sheet.addRule('.' + $lcn.name + ':nth-last-child(' + i + ')', 'display:block;top:' + $lcn.lcn + 'px;');
        $lcn.lcn = Number($lcn.lcn + $lcn.sum);
    };
}
//console封装
var $con = {
    t: function (c) {
        console.log("%c" + 时间 + "%c" + c, "color:#aaa;", "color:#c000ff;");
    }
}
//msg
var $msg = {
    t: function (itemInfo) {
        let sum = $lcn.timer;
        let timer = 时间;
        let li = document.createElement("a");
        li.href = "JavaScript:;";
        li.classList = $lcn.name;
        li.style.animation = "remove 5s";
        li.innerHTML = timer + "  <a href='JavaScript:;'>" + itemInfo + "</a>&nbsp;&nbsp;" + sum + "&nbsp;秒后消息关闭";
        var bbb = setInterval(() => {
            --sum;
            li.innerHTML = timer + "  <a href='JavaScript:;'>" + itemInfo + "</a>&nbsp;&nbsp;" + sum + "&nbsp;秒后消息关闭";
            if (sum == 0) {
                li.classList.add("none");
                li.remove();
                clearInterval(bbb);
            }
        }, 1000);
        document.body.appendChild(li);
        return itemInfo;
    },
    o: function (itemInfo) {
        let sum = $lcn.timer;
        let li = document.createElement("a");
        li.href = "JavaScript:;";
        li.classList = $lcn.name;
        li.innerHTML = "<a href='JavaScript:;'>" + itemInfo + "</a>&nbsp;&nbsp" + sum + "&nbsp;秒后消息关闭";
        var bbb = setInterval(() => {
            --sum;
            li.innerHTML = "<a href='JavaScript:;'>" + itemInfo + "</a>&nbsp;&nbsp;" + sum + "&nbsp;秒后消息关闭";
            if (sum == 0) {
                li.classList.add("none");
                li.remove();
                clearInterval(bbb);
            }
        }, 1000);
        document.body.appendChild(li);
        return itemInfo;
    },
    s: function (itemInfo) {
        let sum = $lcn.timer;
        let li = document.createElement("a");
        li.href = "JavaScript:;";
        li.classList = $lcn.name;
        li.style.animation = "remove 5s";
        li.innerHTML = "<a href='JavaScript:;'>" + itemInfo + "</a>&nbsp;&nbsp;" + sum + "&nbsp;秒后消息关闭";
        var bbb = setInterval(() => {
            --sum;
            li.innerHTML = "<a href='JavaScript:;'>" + itemInfo + "</a>&nbsp;&nbsp;" + sum + "&nbsp;秒后消息关闭";
            if (sum == 0) {
                li.classList.add("none");
                li.remove();
                clearInterval(bbb);
            }
        }, 1000);
        document.body.appendChild(li);
        return itemInfo;
    },
}
const normal_title = document.title;
document.addEventListener('visibilitychange', function () {
    if (document.visibilityState != 'hidden') {
        document.title = normal_title;
    } else {
        document.title = '这么着急就走啦，也不再逛逛？';
    };
});
// window.onerror = function () {
//     return true;
// }
console.log(
    "%c2023-03-03 版本更新, $message文字较多现在更改为$msg           --@一只小初尘", "color: #1eff45;"
);